package com.app.service.impl;


import com.app.dao.AppInfoMapper;
import com.app.dao.AppVersionMapper;
import com.app.entity.AppInfo;
import com.app.entity.AppVersion;
import com.app.entity.bean.Page;
import com.app.entity.bean.AppInfoCondition;
import com.app.service.AppInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AppInfoServiceImpl implements AppInfoService {
    @Autowired
    private AppInfoMapper appInfoMapper;
    @Autowired
    private AppVersionMapper appVersionMapper;
    @Override
    public Page<AppInfo> getAppPage(AppInfoCondition condition) {
        int appCount = appInfoMapper.getAppInfoCount(condition);
        List<AppInfo> appList = appInfoMapper.getAppPage(condition);
        Page<AppInfo> appPage = new Page<>(condition.getPageIndex(),condition.getLimitCount(),appCount,appList);
        return appPage;
    }

    @Override
    public AppInfo getAppInfoById(Long id) {
        return appInfoMapper.getAppInfoById(id);
    }

    @Override
    public AppVersion getAppVersionById(Long id) {
        return appVersionMapper.getAppInfoById(id);
    }

    @Override
    public boolean updateAppInfo(Long id, Long status) {
        int i = appInfoMapper.updateAppInfo(id, status);
        return i==1;
    }
}
